<?php

/**
 * doaddcampaign.php
 * @package adServer
 * @filesource
 */

/*	Close the backdoor	*/
$curPage = strtoupper($_SERVER['PHP_SELF']);
if (isset($curPage) && strpos($curPage, 'INDEX.PHP') === false)
    header('Location:./index.php');

/*	Check if there is a form submitted	*/
if (isset($_POST['campaignName']) && $session->loggedIn == true && $_POST['campaignName'] !=
    '') {
    $campaignName = mysql_real_escape_string($_POST['campaignName']);
    $qry = str_replace('%%CAMPAIGN%%', $campaignName, SQL_CAMPAIGN_EXISTS);
    $error = '';
    if ($session->dbHandle->get_result_bool($qry) == false) {
        $qry = str_replace('%%CAMPAIGN%%', $campaignName,
            SQL_CREATE_CAMPAIGNS_ENTRY);
        $qry = str_replace('%%DESCRIPTION%%', 'n/a', $qry);
        $session->dbHandle->qry($qry);
    } else {
        $error = 'Campaign already exists';
    }


} else {
    $error = 'Illegal operation, please try again';
}

header('Location:./index.php?action=managecampaigns&msg=' . urlencode($error));

?>